View Javadoc
1 /* 2 * Created by IntelliJ IDEA. 3 * User: jbirchfield 4 * Date: Aug 19, 2002 5 * Time: 12:03:45 PM 6 * To change template for new class use 7 * Code Style | Class Templates options (Tools | IDE Options). 8 */ 9 package net.plugin.sql.gui; 10 11 import net.plugin.sql.util.DataSourceManager; 12 import net.plugin.sql.util.DataSourceException; 13 import net.plugin.sql.beans.DataSource; 14 15 import javax.swing.*; 16 import java.awt.*; 17 import java.awt.event.ActionListener; 18 import java.awt.event.ActionEvent; 19 20 import com.intellij.openapi.project.Project; 21 import com.intellij.openapi.project.ProjectManager; 22 23 public class SQLConnectionCreatorFrame extends JInternalFrame implements ActionListener { 24 25 private final Project project; 26 private JLabel nameLabel = null; 27 private JTextField nameTf = null; 28 private JLabel driverLabel = null; 29 private JTextField driverTf = null; 30 private JLabel urlLabel = null; 31 private JTextField urlTf = null; 32 private JLabel userLabel = null; 33 private JTextField userTf = null; 34 private JLabel passwordLabel = null; 35 private JTextField passwordTf = null; 36 37 private JButton addButton = null; 38 39 private JPanel inputPanel = null; 40 private JPanel buttonPanel = null; 41 42 public SQLConnectionCreatorFrame(Project project) { 43 super("Create Data Source", true, true, true, true); 44 this.project = project; 45 46 getContentPane().setLayout(new BorderLayout()); 47 48 nameLabel = new JLabel("Name:"); 49 nameTf = new JTextField(20); 50 driverLabel = new JLabel("Driver:"); 51 driverTf = new JTextField(20); 52 urlLabel = new JLabel("URL:"); 53 urlTf = new JTextField(20); 54 userLabel = new JLabel("Username:"); 55 userTf = new JTextField(20); 56 passwordLabel = new JLabel("Password:"); 57 passwordTf = new JTextField(20); 58 59 inputPanel = new JPanel(new GridLayout(5, 2)); 60 61 inputPanel.add(new JPanel().add(nameLabel)); 62 inputPanel.add(new JPanel().add(nameTf)); 63 inputPanel.add(new JPanel().add(driverLabel)); 64 inputPanel.add(new JPanel().add(driverTf)); 65 inputPanel.add(new JPanel().add(urlLabel)); 66 inputPanel.add(new JPanel().add(urlTf)); 67 inputPanel.add(new JPanel().add(userLabel)); 68 inputPanel.add(new JPanel().add(userTf)); 69 inputPanel.add(new JPanel().add(passwordLabel)); 70 inputPanel.add(new JPanel().add(passwordTf)); 71 72 73 getContentPane().add(inputPanel, BorderLayout.CENTER); 74 75 buttonPanel = new JPanel(); 76 addButton = new JButton("Add Data Source"); 77 addButton.addActionListener(this); 78 buttonPanel.add(addButton); 79 80 getContentPane().add(buttonPanel, BorderLayout.SOUTH); 81 82 } 83 84 public void actionPerformed(ActionEvent e) { 85 System.out.println("action command: " + e.getActionCommand()); 86 if (e.getSource().equals(addButton)) { 87 DataSource dataSource = new DataSource(); 88 dataSource.setName(nameTf.getText()); 89 dataSource.setDriver(driverTf.getText()); 90 dataSource.setUrl(urlTf.getText()); 91 dataSource.setUser(userTf.getText()); 92 dataSource.setPassword(passwordTf.getText()); 93 try { 94 DataSourceManager.getInstance(project).addDataSource(dataSource); 95 } catch (DataSourceException e1) { 96 JOptionPane.showMessageDialog(null, e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); 97 } 98 } 99 } 100 101 102 }

This page was automatically generated by Maven